<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>艾家艾产品线上销售平台</title>
    <link rel="shortcut icon" href="../img/favicon.ico">
    <link rel="stylesheet" href="../css/reset.css"/>
    <link rel="stylesheet" href="../css/register-password.css"/>
    <script src="../them/jquery/jquery-1.7.2.js"></script>
    <script src="../them/jquery/jquery.cookie.js"></script>
</head>
<body>
<div class="box">
    <div class="header">
        <div class="header-logo">
            <div class="logo_b"></div>
            <div class="tittle">
                <p style="font-size: 32px;margin-bottom: 60px">重置密码</p>
            </div>
        </div>
    </div>
    <div class="mes">
        <p>请重设您账号的密码</p>
    </div>
    <div class="regbox">
        <form method="post">
            <input type="password"  placeholder="请输入新密码" id="pass">
            <input type="password"  placeholder="请再次输入新密码" id="confirm">
            <p class="hint verify-text"></p>
        </form>
        <a class="btn" href="javascript:;">提交</a>
    </div>
</div>
<div class="footer">
    <div class="footer-are">
        <a href="javascript:;">简体</a>
        <span> | </span>
        <a href="javascript:;">繁体</a>
        <span> | </span>
        <a href="javascript:;">English</a>
        <span> | </span>
        <a href="javascript:;">常见问题</a>
    </div>
    <div class="footer-info">
        <p>艾家艾草公司版权所有-京ICP备10046444-京公网安备11010802020134号-京ICP证110507号</p>
    </div>
</div>
</body>
</html>
<script>
    var user_name=$.cookie("user_name");
    var forgetToken=$.cookie("forgetToken");
    if(!forgetToken || !user_name){
        $('.verify-text').html('您停留的时间太长，请从新申请重置密码');
    }

    $('#pass').focus();
    $('#pass').blur(function(){
        if(!$(this).val()){
            $('.verify-text').html('密码不能为空');
        }else{
            $('.verify-text').html('');
        }
    });
    $('#confirm').blur(function(){
        if(!$(this).val()){
            $('.verify-text').html('请再次输入新密码');
        }else{
            $('.verify-text').html('');
        }
        if($('#pass').val()!=$(this).val()){
            $('.verify-text').html('两次输入的密码不一致');
        }else{
            $('.verify-text').html('');
        }
    });
    var new_password;
    $('.btn').click(function(){
        if($('.verify-text').html()==''){
            new_password=$('#pass').val();
            $.ajax({
                url:'/user/forget_reset_password.do',
                data:{
                    'username':user_name,
                    'passwordNew':new_password,
                    'forgetToken':forgetToken
                },
                type:'post',
                success:function(res){
                    alert(res.msg+'去登陆');
                    window.location.href = "login.html";
                },
                error:function(){

                }
            });
        }
    });

</script>